#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time: 2020/5/6  16:06
# @Author: 余浪人
# @email: yulangren520@gmail.com
from flask import Flask, jsonify

from verify import pool_inland, pool_foreign

api_bp = Flask(__name__)
api_bp.config['JSON_AS_ASCII'] = False


@api_bp.route('/')
def index(): return '小鬼，这里没有东西哟...'


@api_bp.route('/get_inland', methods=['GET'])
def get_inland():
    ip_port = pool_inland()
    if ip_port:
        ip_port.update({'code':0,'msg':'success'})
        return jsonify(ip_port)
    return jsonify({'code': 4, 'msg': '代理池为空！'})


@api_bp.route('/get_foreign', methods=['GET'])
def get_foreign():
    ip_port = pool_foreign()
    if ip_port:
        ip_port.update({'code': 0, 'msg': 'success'})
        return jsonify(ip_port)
    return jsonify({'code': 4, 'msg': '代理池为空！'})
